/*
 * Copyright (c) 2021, MegaEase
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.megaease.easeagent.zipkin.impl;

import com.megaease.easeagent.plugin.api.trace.Request;
import com.megaease.easeagent.plugin.api.trace.Span;

import java.util.HashMap;
import java.util.Map;

public class RequestMock implements Request {
    private String name;
    private Span.Kind kind;
    private boolean cacheScope = false;
    private Map<String, String> headers = new HashMap<>();

    public RequestMock setName(String name) {
        this.name = name;
        return this;
    }

    public RequestMock setKind(Span.Kind kind) {
        this.kind = kind;
        return this;
    }

    public RequestMock setCacheScope(boolean cacheScope) {
        this.cacheScope = cacheScope;
        return this;
    }

    public RequestMock setHeaders(Map<String, String> headers) {
        for (Map.Entry<String, String> entry : headers.entrySet()) {
            this.headers.put(entry.getKey(), entry.getValue());
        }
        return this;
    }

    @Override
    public Span.Kind kind() {
        return kind;
    }

    @Override
    public String header(String name) {
        return headers.get(name);
    }

    @Override
    public String name() {
        return name;
    }

    @Override
    public boolean cacheScope() {
        return cacheScope;
    }

    @Override
    public void setHeader(String name, String value) {
        headers.put(name, value);
    }

    public Map<String, String> getHeaders() {
        return headers;
    }


}
